home *** CD-ROM | disk | FTP | other *** search
- --
- -- control options menu page
- --
-
-
- UI.PageOptionsControl=
- {
- KeyOrder=
- {
- MOVEMENT=
- {
- "MoveForward",
- "MoveBackward",
- "MoveLeft",
- "MoveRight",
- "Jump",
- "Crouch",
- "Prone",
- "Walk",
- "SprintRun",
- "LeanLeft",
- "LeanRight",
- },
-
- MULTIPLAYER=
- {
- "Chat",
- "TeamChat",
- "ViewScoreboard",
- },
-
- GAME=
- {
- "Use",
- "HoldBreath",
- "ToggleFlashlight",
- "Binoculars",
- "ThermalVision",
- "TakeScreenshot",
- },
-
- COMBAT=
- {
- "Fire",
- "Reload",
- "ToggleFiremode",
- "NextWeapon",
- "PrevWeapon",
- "DropWeapon",
- "CycleGrenade",
- "ThrowGrenade",
- "ToggleZoom",
- "ZoomIn",
- "ZoomOut",
- "Slot1",
- "Slot2",
- "Slot3",
- "Slot4",
- },
- },
-
- GUI=
- {
- sensitivitytext=
- {
- skin = UI.skins.Label,
- left = 200, top = 415,
- width = 142, height = 28,
-
- text=Localize("MouseSensitivity"),
- },
-
- sensitivity=
- {
- skin = UI.skins.HScrollBar,
-
- left = 350, top = 419,
- width = 200,
-
- tabstop = 2,
-
- OnChanged = function(Sender)
- Input:SetMouseSensitivity(Sender:GetValue()*50.0+5.0);
- end,
- },
-
- invertmousetext=
- {
- skin = UI.skins.Label,
-
- left = 590, top = 415,
- width = 112,
-
- text=Localize("InvertMouse"),
- },
-
- invertmouse=
- {
- skin = UI.skins.CheckBox,
-
- left = 710, top = 417,
-
- tabstop = 3,
-
- OnChanged=function(Sender)
- if (Sender:GetChecked()) then
- Input:SetInvertedMouse(1);
- else
- Input:SetInvertedMouse(0);
- end
- end,
- },
-
- controllist=
- {
- skin = UI.skins.ListView,
-
- left = 200, top = 140,
- width = 580, height = 259,
- color = "0 0 0 96",
-
- nosort = 1,
-
- tabstop = 1,
-
- vscrollbar=
- {
- skin = UI.skins.VScrollBar,
- },
-
- hscrollbar=
- {
- skin = UI.skins.HScrollBar,
- }
- },
-
- reset=
- {
- skin = UI.skins.BottomMenuButton,
- left = 780-180-178.5,
-
- tabstop = 4,
-
- text=Localize("RestoreDefaults"),
-
- OnCommand=function(Sender)
-
- Input:ResetToDefaults();
-
- UI.PageOptionsControl.GUI.invertmouse:SetChecked(0);
- UI.PageOptionsControl.GUI.sensitivity:SetValue(0.35);
-
- UI.PageOptionsControl.GUI.sensitivity:OnChanged(UI.PageOptionsControl.GUI.sensitivity);
- UI.PageOptionsControl.GUI.invertmouse:OnChanged(UI.PageOptionsControl.GUI.invertmouse);
-
- UI.PageOptionsControl.FillBindList();
- end,
- },
-
- change=
- {
- skin = UI.skins.BottomMenuButton,
- left = 780-180,
-
- tabstop = 5,
-
- text=Localize("ChangeCtrlBind"),
-
- OnCommand=function(Sender)
- if UI.PageOptionsControl.GUI.controllist:GetSelectionCount()==1 then -- something selected ???
- local index=UI.PageOptionsControl.GUI.controllist:GetSelection(0);
- local Action=UI.PageOptionsControl.Actions[index];
- if (Action.configurable) then
- UI.PageWaitForKey:SetLabel(Action);
- UI:ActivateScreen("BindWaitForKey");
- end
- end
- end,
- },
-
- OnActivate= function(Sender)
- local inv=0;
- if Input:GetInvertedMouse() then
- inv=1;
- end
-
- -- invert mouse
- UI.PageOptionsControl.GUI.invertmouse:SetChecked(inv);
-
- -- controls
- UI.PageOptionsControl.GUI.controllist:ClearColumns();
- UI.PageOptionsControl.GUI.controllist:Clear();
- UI.PageOptionsControl.GUI.controllist.OnCommand=UI.PageOptionsControl.GUI.change.OnCommand;
-
- UI.PageOptionsControl.GUI.controllist:AddColumn(Localize("CtrlActionName"), 270, UIALIGN_RIGHT, UI.szListViewOddColor, "0 0 0 0");
- UI.PageOptionsControl.GUI.controllist:AddColumn(Localize("CtrlActionBinding1"), 144, UIALIGN_CENTER, UI.szListViewEvenColor, "0 0 0 12");
- UI.PageOptionsControl.GUI.controllist:AddColumn(Localize("CtrlActionBinding2"), 144, UIALIGN_CENTER, UI.szListViewOddColor, "0 0 0 0");
-
- UI.PageOptionsControl.FillBindList();
-
- -- sensitivity
- UI.PageOptionsControl.GUI.sensitivity:SetValue((Input:GetMouseSensitivity()-5.0)/50.0);
-
- -- ControlSettingsPage.WarningText=self:CreateStatic(150, 570, 650, 20, 0, "");
-
- end,
- },
-
- ------------------------------------------------------------------------
-
- Actions=nil, --
- }
-
- function UI.PageOptionsControl:AddBind(Action)
- if ((not Action) or (not Action.actionmaps[1])) then
- return nil
- end
-
- local Binding = Input:GetBinding(Action.actionmaps[1], Action.id);
- local b1="";
- local b2="";
-
- if (Binding[1]) then
- if (Binding[1].mod) then
- b1=Binding[1].mod.." + "..Binding[1].key;
- else
- b1=Binding[1].key;
- end
- end
-
- if (Binding[2]) then
- if (Binding[2].mod) then
- b2=Binding[2].mod.." + "..Binding[2].key;
- else
- b2=Binding[2].key;
- end
- end
-
- return UI.PageOptionsControl.GUI.controllist:AddItem(Action.desc, b1, b2);
- end
-
- -------------------------------------------------------------------------
- function UI.PageOptionsControl.FillBindList()
-
- UI.PageOptionsControl.GUI.controllist:Clear();
- UI.PageOptionsControl.Actions={};
-
- local ActionList = Game:GetActions();
- local ActionMap = {};
-
- for i, Action in ActionList do
- if (Action.configurable and Action.configurable ~= 0) then
- if (not ActionMap[Action.type]) then
- ActionMap[Action.type] = {};
- end
-
- tinsert(ActionMap[Action.type], Action);
- ActionMap[Action.type].n = nil;
- end
- end
-
- for szType, Map in ActionMap do
-
- local szTypeTitle = "["..strupper(szType).."]";
- local MapOrder = UI.PageOptionsControl.KeyOrder[strupper(szType)];
-
- UI.PageOptionsControl.GUI.controllist:AddItem("$$8"..szTypeTitle.."$1$");
-
- for i, szActionName in MapOrder do
- for j, Action in Map do
-
- -- find the key in the list of keys with this szType
- if (strlower(strsub(Action.desc, 2)) == strlower(szActionName)) or
- (strlower(strsub(Action.desc, 1)) == strlower(szActionName)) then
- local iIndex = UI.PageOptionsControl:AddBind(Action);
-
- if (iIndex) then
- UI.PageOptionsControl.Actions[iIndex] = Action;
- break;
- end
- end
- end
- end
- end
- end
-
- UI:CreateScreenFromTable("ControlOptions",UI.PageOptionsControl.GUI);